<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录页</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery-3.7.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>

    <style>
        b{
            font-weight: bolder;
            color: red;
        }
    </style>
    <link rel="stylesheet" href="/plugins/bootstraptable/bootstrap-table.min.css">


</head>
<body>

<div class="container-fluid">

    <div class="panel panel-default">
        <div class="panel-heading">Panel heading without title</div>
        <div class="panel-body">

            <form>
                <div class="form-group">
                    <label for="username">用户名:</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="用户名">
                </div>
                <div class="form-group">
                    <label for="password">密码:</label>
                    <input type="password" class="form-control" id="password" name="password" placeholder="密码">
                </div>

                <button type="button" class="btn btn-default" onclick="login();">登录</button>

            </form>

        </div>

    </div>

</div>

<script type="text/javascript">

    function login(){
        var name=$("#username").val();
        var password=$("#password").val();

        $.ajax({
            url:"/webapi/login/user",
            data:{
                username:name,
                password:password
            }
        }).done(function(rs){
            if(rs>=0){
                //成功
                window.location.href="/student/list";
            }else{
                alert("出错了，你的用户名和密码是乱写的吗？");
            }

        });

    }


</script>


</body>
</html>